Blockly.JavaScript = Blockly.Generator.get('JavaScript');
Blockly.Language.gamedu_move = {
	// Block for moving forward or backward.
	helpUrl : 'http://code.google.com/p/blockly/wiki/Move',
	init : function() {
		this.setColour(290);
		this.appendValueInput('uid')
				 .appendTitle(Blockly.MSG_MOVE)
		this.appendDummyInput()
		 	.appendTitle(" ")
			.appendTitle(new Blockly.FieldDropdown(this.DIRECTIONS), 'DIR');
		this.setPreviousStatement(true);
		this.setNextStatement(true);
		 this.setInputsInline(true);
		this.setTooltip(Blockly.MSG_MOVETOOLTIP);
	}
};


Blockly.Language.gamedu_move.DIRECTIONS = [[Blockly.MSG_MOVEUP, 'moveUp'], [Blockly.MSG_MOVELEFT, 'moveLeft'], [Blockly.MSG_MOVEDOWN, 'moveDown'], [Blockly.MSG_MOVERIGHT, 'moveRight']];

Blockly.JavaScript.gamedu_move = function() {
	var object = Blockly.JavaScript.valueToCode(this, 'uid', Blockly.JavaScript.ORDER_MEMBER) || '\'\'';	
	return 'gamedugame.blockly.' + this.getTitleValue('DIR') + '(\'' + this.id +'\',' +object+ ');\n';
};


Blockly.Language.gamedu_drophold = {
	// Block for moving forward or backward.
	helpUrl : 'http://code.google.com/p/blockly/wiki/Move',
	init : function() {
		this.setColour(290);
		this.appendValueInput('uid');
		this.appendDummyInput()
			//.appendTitle(Blockly.MSG_REALIZE)
			.appendTitle("")
			.appendTitle(new Blockly.FieldDropdown(this.ACTIONS), 'ACT');
		this.setPreviousStatement(true);
		this.setNextStatement(true);
		 this.setInputsInline(true);
		this.setTooltip('');
	}
};


Blockly.Language.gamedu_drophold.ACTIONS = [[Blockly.MSG_REALIZEDROP, 'drop'], [Blockly.MSG_REALIZEHOLD, 'hold']];

Blockly.JavaScript.gamedu_drophold = function() {
	var object = Blockly.JavaScript.valueToCode(this, 'uid', Blockly.JavaScript.ORDER_MEMBER) || '\'\'';	
	
	return 'gamedugame.blockly.' + this.getTitleValue('ACT') + '(\'' + this.id +'\',' +object+ ');\n';
};



Blockly.Language.gamedu_drophold = {
	// Block for moving forward or backward.
	helpUrl : 'http://code.google.com/p/blockly/wiki/Move',
	init : function() {
		this.setColour(290);
		this.appendValueInput('uid');
		this.appendDummyInput()
			//.appendTitle(Blockly.MSG_REALIZE)
			.appendTitle("")
			.appendTitle(new Blockly.FieldDropdown(this.ACTIONS), 'ACT');
		this.setPreviousStatement(true);
		this.setNextStatement(true);
		 this.setInputsInline(true);
		this.setTooltip('');
	}
};


Blockly.Language.gamedu_drophold.ACTIONS = [[Blockly.MSG_REALIZEDROP, 'drop'], [Blockly.MSG_REALIZEHOLD, 'hold']];

Blockly.JavaScript.gamedu_drophold = function() {
	var object = Blockly.JavaScript.valueToCode(this, 'uid', Blockly.JavaScript.ORDER_MEMBER) || '\'\'';	
	
	return 'gamedugame.blockly.' + this.getTitleValue('ACT') + '(\'' + this.id +'\',' +object+ ');\n';
};




Blockly.Language.gamedu_shoot = {
	// Block for moving forward or backward.
	helpUrl : 'http://code.google.com/p/blockly/wiki/Move',
	init : function() {
		this.setColour(290);
		this.appendValueInput('uid');
		this.appendDummyInput()
			.appendTitle(Blockly.MSG_SHOOT);
		this.setPreviousStatement(true);
		this.setNextStatement(true);
		 this.setInputsInline(true);
		this.setTooltip('');
	}
};


Blockly.JavaScript.gamedu_shoot = function() {
	var object = Blockly.JavaScript.valueToCode(this, 'uid', Blockly.JavaScript.ORDER_MEMBER) || '\'\'';	
	return 'gamedugame.blockly.shoot (\'' + this.id +'\',' +object+ ');\n';
};


Blockly.Language.gamedu_cuboVermelho = {
	// Block for moving forward or backward.
	helpUrl : 'http://code.google.com/p/blockly/wiki/Move',
	init : function() {
		this.setColour(290);	
		var image = new Blockly.FieldImage('images/truck.png', 25, 25);
		this.appendDummyInput().appendTitle(image, 'VALUE', 12);
		this.setTooltip('');   
    	this.setOutput(true, Number);
 
	}

};

Blockly.JavaScript.gamedu_cuboVermelho = function() {
	return [12,0];
}


Blockly.Language.gamedu_cuboAzul = {
	// Block for moving forward or backward.
	helpUrl : 'http://code.google.com/p/blockly/wiki/Move',
	init : function() {
		this.setColour(290);	
		var image = new Blockly.FieldImage('images/hook.png', 25, 25);
		this.appendDummyInput().appendTitle(image, 'VALUE', 12);
		this.setTooltip('');   
    	this.setOutput(true, Number);
 
	}
	
};

Blockly.JavaScript.gamedu_cuboAzul = function() {
	return [17,0];
};
